import { Inject, Injectable } from '@nestjs/common';
import { Repository } from 'typeorm';
import { Department } from './department.mysql.entity';
import { DepartmentCreateDto } from './dto/create-department.dto';
@Injectable()
export class DepartmentService {
  constructor(
    @Inject('DEPARTMENT_REPOSITORY')
    private departmentRepository: Repository<Department>,
  ) {}

  create(createDepartmentDto: DepartmentCreateDto) {
    return this.departmentRepository.save({
      departmentName: createDepartmentDto.name,
    });
  }

  findAll() {
    return this.departmentRepository.find({ relations: ['users'] });
  }
}
